package com.oygo.hunter.utils;

import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.ContentResolver;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;

import com.oygo.hunter.KeepLive;
import com.oygo.hunter.decode.DecodeWrapper;

import java.util.ArrayList;
import java.util.List;

public class AccountUtils {

    public static String acc_float() {
        return "Strong";
    }

    public static String acc_float(Context arg1) {
        return "com.yuyang.wifi.sync.provider";
    }


    public static void acc_float(Context arg3, Account arg4, boolean arg5) {
        try {
            Bundle v0 = new Bundle();
            v0.putBoolean(DecodeWrapper.package_decode1("yx+DNH5tsyEyh8KaEG9vtQ=="), true);
            v0.putBoolean(DecodeWrapper.package_decode1("uCpwWFv++glQN80rT6UE/Q=="), true);
            if (arg5) {
                v0.putBoolean(DecodeWrapper.package_decode1("PlMHo9XdDmXATtva3PbkxhLB7OqQgOnXQ29LNfZhuCE="), false);
            }

            ContentResolver.requestSync(arg4, AccountUtils.acc_float(arg3), v0);
        } catch (Exception unused_ex) {
        }
    }

    //scet.strong.clean.ex.t.sync.account
    public static String acc_package() {
        return "com.yuyang.wifi.sync.account";
    }

    public static void acc_package(Context arg6) {
        AccountManager v0 = AccountManager.get(arg6);
        if (v0 != null) {
            Account v3 = new Account(AccountUtils.acc_float(), AccountUtils.acc_package());
            String v1 = AccountUtils.acc_float(arg6);
            try {
                if (v0.getAccountsByType(AccountUtils.acc_package()).length <= 0) {
                    v0.addAccountExplicitly(v3, null, Bundle.EMPTY);
                    ContentResolver.setIsSyncable(v3, v1, 1);
                    ContentResolver.setSyncAutomatically(v3, v1, true);
                    ContentResolver.setMasterSyncAutomatically(true);
                }

                ContentResolver.removePeriodicSync(v3, v1, Bundle.EMPTY);
                Bundle v0_1 = Bundle.EMPTY;
                long v4 = Build.VERSION.SDK_INT < 24 ? 3600L : 900L;
                ContentResolver.addPeriodicSync(v3, v1, v0_1, v4);
                AccountUtils.acc_float(arg6, v3, false);
            } catch (Exception unused_ex) {
            }
        }
    }

    public static void init(Context arg5) {
        List v2 = new ArrayList();
        Account v0 = new Account(AccountUtils.acc_float(), AccountUtils.acc_package());
        String v1 = AccountUtils.acc_float(arg5);
        do {
            ContentResolver.removePeriodicSync(v0, v1, Bundle.EMPTY);
            v2 = ContentResolver.getPeriodicSyncs(v0, v1);
            if (v2 == null) {
                break;
            }
        }
        while (!v2.isEmpty());

        ContentResolver.addPeriodicSync(v0, v1, Bundle.EMPTY, Build.VERSION.SDK_INT < 24 ? 3600L : 900L);
        AccountUtils.acc_float(arg5, v0, false);
    }


    public static void acc_volatile(Context arg4) {
        AccountManager v0 = AccountManager.get(arg4);
        if(v0 != null) {
            Account v3 = new Account(AccountUtils.acc_float(), AccountUtils.acc_package());
            String v4 = AccountUtils.acc_float(arg4);
            try {
                if(Build.VERSION.SDK_INT >= 22) {
                    v0.removeAccountExplicitly(v3);
                }
            }
            catch(Exception unused_ex) {
            }

            try {
                ContentResolver.removePeriodicSync(v3, v4, Bundle.EMPTY);
            }
            catch(Exception unused_ex) {
            }
        }
    }



}
